import Vue from "vue"
import Router from "vue-router"

import Empty from "@/layout/empty"
import Login from "@/layout/login"
import Main from "@/layout/main"
import leftBar from "@/layout/leftBar"
import topBar from "@/layout/topBar"

Vue.use(Router)

export default new Router({
  base:'/admin/',
  mode: 'history',
  routes: [
    {
      path: "/",
      redirect: '/login/login'
    },
    {
      // 纯测试，可删除
      path: "/test",
      component: () => import('@/pages/test/test')
    },
    {
      path: "/login/",
      component: Login,
      redirect: '/login/login',
      children: [
        {
          path: 'login',
          meta: {
            title: '登录'
          },
          component: () => import('@/pages/login/login')
        },
        {
          path: 'logout',
          meta: {
            title: '退出登录'
          },
          component: () => import('@/pages/login/logout')
        }
      ]
    },
    {
      path: "/home/",
      name: 'home',
      component: Main,
      redirect: '/home/dash',
      children: [
        {
          path: 'dash',
          redirect: '/user/list'
        }
      ]
    },
    {
      path: '/user/',
      component: Main,
      redirect: '/user/list',
      children: [
        {
          path: 'list',
          meta: {
            title: '用户列表'
          },
          components: {
            default: () => import('@/pages/user/list'),
            leftBar: leftBar,
            topBar: topBar
          }
        },
        {
          path: 'modify',
          meta: {
            title: '用户',
            prevPath: '/user/list'
          },
          components: {
            default: () => import('@/pages/user/modify'),
            leftBar: leftBar,
            topBar: topBar
          }
        }
      ]
    },
    {
      path: '/notes/',
      component: Main,
      redirect: '/notes/list',
      children: [
        {
          path: 'list',
          meta: {
            title: '笔记列表'
          },
          components: {
            default: () => import('@/pages/notes/list'),
            leftBar: leftBar,
            topBar: topBar
          }
        },
        {
          path: 'detail',
          meta: {
            title: '笔记',
            prevPath: '/notes/list'
          },
          components: {
            default: () => import('@/pages/notes/detail'),
            leftBar: leftBar,
            topBar: topBar
          }
        },
        {
          path: 'recycle',
          meta: {
            title: '回收站'
          },
          components: {
            default: () => import('@/pages/notes/recycle'),
            leftBar: leftBar,
            topBar: topBar
          }
        }
      ]
    }
  ]
})
